cmake_minimum_required(VERSION 3.10)

project(wRect)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


if(WIN32)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core WinExtras Svg)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core WinExtras Svg)
else()
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core  Svg)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core  Svg)
endif()



include_directories(SYSTEM "./src")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    add_definitions(-DQ_DEBUG)
endif()

set(RESOURCES
    src/res.qrc
)

qt5_add_resources(RESOURCE_ADDED ${RESOURCES})


add_library(wRect SHARED
    ${RESOURCE_ADDED}
    src/global.h
    src/w_main_window.h src/w_main_window.cpp
    src/w_window_resizer.h src/w_window_resizer.cpp
    src/w_qss.h src/w_qss.cpp
    src/w_window_nclient.h src/w_window_nclient.cpp
    src/w_system_button.h src/w_system_button.cpp
    src/w_dialog.h src/w_dialog.cpp
    src/w_tags.h src/w_tags.cpp
    src/w_flow_layout.h src/w_flow_layout.cpp
    src/w_toast.h src/w_toast.cpp
    src/w_spin.h src/w_spin.cpp
    src/w_progress_bar.h src/w_progress_bar.cpp
    src/w_window.h src/w_window.cpp
    src/w_badge.h src/w_badge.cpp

)




if(WIN32)

target_link_libraries(wRect PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::WinExtras Qt${QT_VERSION_MAJOR}::Svg)

else()
    target_link_libraries(wRect PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core  Qt${QT_VERSION_MAJOR}::Svg)

endif()

target_compile_definitions(wRect PRIVATE WRECT_LIBRARY)


if(WIN32)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy  ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.dll        ${CMAKE_BINARY_DIR}/src/${PROJECT_NAME}.dll
    COMMENT "Copying file to binary directory"
)
else()

endif()


################demo#################################

#add_executable(demo
#    demo/main.cpp
#)
#target_link_libraries(demo PRIVATE Qt${QT_VERSION_MAJOR}::Widgets wRect)

